﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
using Rose.Models;
using Rose.Movies;


namespace Rose.Helper
{

    public class MovieHelpModel
    {
        
   
        private Database_MovieEntities db_movie = new Database_MovieEntities();

        #region 前台显示

        public List<string> GetTodayMovie(int cameraId,string savepath)
        {
            DateTime today = DateTime.Today;
            List<string> returnModel = new List<string>();
            var movies = db_movie.Movies.Where(c => c.CameraId == cameraId && c.Time == today);

            if (movies.Count() <= 0)
            {
                Camera camera = db_movie.Cameras.Where(c => c.CameraId == cameraId).FirstOrDefault();
                if (camera == null)
                {
                    return returnModel;
                }

                CollectMovieDataHelpModel collect = new CollectMovieDataHelpModel();
                collect.CollectData(camera,savepath);

                movies = db_movie.Movies.Where(c => c.CameraId == cameraId && c.Time == today);
                //重新搜索数据库看有没有添加成功;
            }


            foreach (var item in movies)
            {
                returnModel.Add(item.Content);
            }

            return returnModel;
            ///还未进行本地的图片化处理
            ///
        }

        #endregion






        #region 后台操作，搜集数据



        #endregion


    }
} 








